package com.yykj.hospital.server.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yykj.common.vo.ResultVO;
import com.yykj.hospital.client.dto.HospitalOfficerDTO;
import com.yykj.hospital.server.form.HospitalOfficerEditForm;
import com.yykj.hospital.server.service.HospitalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/backstage/hospital")
@Api(tags = {"医院职称管理"})
@SuppressWarnings("unchecked")
public class HospitalOfficerController {
    @PostMapping("/officer/add")
    @ApiOperation("职称--添加")
    @ApiOperationSupport(ignoreParameters = {"id"})
    public ResultVO<HospitalOfficerDTO> addHospitalDepartment(@RequestBody HospitalOfficerEditForm form){
        return ResultVO.success(hospitalService.editHospitalOfficer(form));
    }

    @PutMapping("/officer/edit")
    @ApiOperation("职称--修改")
    public ResultVO<HospitalOfficerDTO> editHospitalDepartment(@RequestBody HospitalOfficerEditForm form){
        return ResultVO.success(hospitalService.editHospitalOfficer(form));
    }

    @GetMapping("/officer/list")
    @ApiOperation("职称--列表")
    public ResultVO<HospitalOfficerDTO> listHospitalDepartment(@RequestParam(name = "hospitalId") Integer hospitalId){
        return ResultVO.success(hospitalService.listHospitalOfficer(hospitalId));
    }

    @DeleteMapping("/officer/delete/{id}")
    @ApiOperation("职称--删除")
    public ResultVO<HospitalOfficerDTO> deleteHospitalDepartment(@PathVariable Integer id){
        hospitalService.deleteHospitalOfficer(id);
        return ResultVO.success();
    }

    private HospitalService hospitalService;

    @Autowired
    public void setHospitalService(HospitalService hospitalService) {
        this.hospitalService = hospitalService;
    }
}
